<?php
$page_name=basename($_SERVER['SCRIPT_FILENAME']);
$IsPreserved	= 'Y';
$IsProcess		= $_REQUEST['IsProcess'];
include "general_include.php";
include "checklogin.php";
if($IsProcess <> 'Y')
{
	include "top.php";
	include "left.php";
}
function findvalue($table,$fld_name,$fld_value,$find_value)
	{
		 if($fld_value=='')
				return false;
				
			$SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
			$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
			return $SelectType[0];
	}	

$item_per_page=$_SESSION['item_per_page'] = $_REQUEST['item_per_page'];
	if(empty($item_per_page) || !isset($item_per_page))
	{
	$item_per_page=9;
	} 

$action	= $_REQUEST['action'];


/*function findvalue($table,$fld_name,$fld_value,$find_value)
{
     if($fld_value=='')
			return false;
			
		$SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
		$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
		return $SelectType[0];
}	
*/

/* Front Pagination Object Creation Starts */		
//	$PaginationFrontObj=new PaginationClassFrontAjax(10,3,1);
/* Front Pagination Object Creation Ends */


$ReturnSortingArr=$SortingObjAjax->Sorting("v.overall_rating ASC,v.date_added DESC","v.overall_rating",$OrderType);
$OrderBySql=$ReturnSortingArr['OrderBySql'];
$OrderLink=$ReturnSortingArr['OrderLink'];
$OrderType=$ReturnSortingArr['OrderType'];	

 $SelectvdoSQL="SELECT ufav.*,v.*,DATE_FORMAT(v.date_added,'%M %d , %Y') as video_date FROM ".TABLEPREFIX."_user_fav_video ufav , ".TABLEPREFIX."_video v WHERE ufav.user_id='".$_SESSION['user_id']."' and ufav.video_id=v.video_id".$OrderBySql;
// $PreserveLink="from=$from&from_page=$from_page&".$OrderLink;
// $preserve_variable_object->PreserveVariableUpdate($PreserveLink);
 $PaginationObjAjaxLatest=new PaginationClassAjax($item_per_page,"prev",'',"next","active",$adodbcon);
 $pagination_arr = $PaginationObjAjaxLatest->PaginationAjax($SelectvdoSQL,$page_name."?action=".$action."&item_per_page=".$item_per_page,"Managergeneral");
	/* pagination ends */
 //echo $pagination_arr[0];	
 $VideoArr=$UserManagerObjAjax->GetRecords("All",$pagination_arr[0]);

 $NumVideo=count($VideoArr);
	
for($i=0;$i<$NumVideo;$i++)
{
	$VideoArr[$i]['title']=show_to_control($VideoArr[$i]['title']);
	
	$VideoArr[$i]['user'] = findvalue(TABLEPREFIX."_user","user_id",$VideoArr[$i]['user_id'],"name");
	$totstar='';
	for($x=1;$x<=$VideoArr[$i]['overall_rating'];$x++)
	{
	  $totstar.="<img src='images/star-c.gif' alt='' border='0' />";
	}
	$istar=5 - $VideoArr[$i]['overall_rating']; 
	for($y=1;$y<=$istar;$y++)
	{
	  $totstar.="<img src='images/star-g.gif' alt='' border='0' />";
	}
	$VideoArr[$i]['star']=$totstar;
	$viewCount = "SELECT count(*) FROM ".TABLEPREFIX."_video_view_count WHERE video_id =".$VideoArr[$i]['video_id'];
	$viewArr = $UserManagerObjAjax->GetRecords("Row",$viewCount);
	$VideoArr[$i]['view_count'] = $viewArr[0];
	
}


$smarty->assign('page_name',$page_name);
$smarty->assign('from',$from);
$smarty->assign('from_page',$from_page);
$smarty->assign('PreserveLink',$PreserveLink);
$smarty->assign('OrderType',$OrderType);
$smarty->assign("VideoArr",$VideoArr);
$smarty->assign('pagination_arr',$pagination_arr);	
$smarty->assign("NumVideo",$NumVideo);
$smarty->display('my_video.tpl');
if($IsProcess <> 'Y')
	 include "footer.php";
?>